package com.qf.day4.work;

import java.util.Arrays;

public class Work2 {

    public  static int killGame(int[] arr) {
        int peo = arr.length;
        int count = 1;
          while(peo!=1){
            for (int i = 0; i < arr.length; i++) {
                if(! (arr[i]==-1)){
                    if(count++ ==3){
                        arr[i]=-1;
                        count=1;
                        peo--;
                    }
                }
            }
        }
        for (int n:arr) {
            if(n!=-1){
                return n;
            }
        }
        return -1;
    }
    public static void main(String[] args) {
        int[] arr = {0,1,2,3,4,5,6,7};
        System.out.println(killGame(arr));
    }
}
